<?php

/**
 * Description of JSONmessage
 *
 * @author thomas
 */
class JSONmessage {
    private $_message, $_statut, $_boutiques, $_hashmap;
    
    public function __construct(){
        $this->_message = "";
        $this->_statut = 0;
        $this->_boutiques = "";
        $this->_hashmap = array();
    }
    
    public function getMessage(){return $this->_message;}
    public function getSatut(){return $this->_statut;}
    public function getBoutique(){return $this->_boutiques;}
    public function getHashmap(){return $this->_hashmap;}
    public function getHashmapValue($key){return $this->_hashmap[$key];}
    
    public function setMessage($mess){
        $this->_message = $mess;
    }
    public function setSatut($statut){
        $this->_statut = $statut;
    }
    public function setBoutiques($boutique){
        $this->_boutiques = $boutique;
    }
    public function setHashmap($array){
        $this->_hashmap = $array;
    }
    
    
    public function toBoutiquesJSON(){
        $jsonString = "{";
        $jsonString .= " \"message\" : \"".$this->_message."\",";
        $jsonString .= " \"statut\" : \"".$this->_statut."\",";
        $jsonString .= " \"boutiques\" : [".$this->getLesCollectionsJSON($this->_boutiques)."]";
        $jsonString .= "}";
        return $jsonString;
        
    }
    
    public function toJSON(){
        return json_encode(get_object_vars($this));
    }
    
    
    
     public function getLesCollectionsJSON($collection){
        $collectionJson = "";
        foreach($collection as $objet){
            $collectionJson .= $objet->toJSON().",";
        }
        $collectionJson = substr($collectionJson, 0, -1);
        return $collectionJson;
    }
}


?>
